<template>
    <div class="reCharge_page">
      <van-nav-bar
        title=""
        left-arrow
        @click-left="goBack"
        left-text="返回"
        />
        <div class='head_img_box'>
          <div class='head_img'>
              <div class='head'>
                  <img :src="userInfo.avatar" style='width:100%;height:100%;border-radius: 30px;' alt="">
              </div>
              <div>
                <div class='nickname'>近聘昵称:{{userInfo.nick_name}}</div>
                <div class='nickname'>近聘账号:{{userInfo.ids}}</div>
                <div class='nickname'>近聘手机号:{{userInfo.mobile}}</div>
              </div> 
          </div>
        </div>
        <!-- <div>温馨提示：使用以上账号添加一下账号为好友，点击添加到好友列表即可添加好友。</div> -->
        <div class='head_img_box'>
            <div class='head_img'>
                <div class='head'>
                    <img :src="userFriendInfo.avatar" style='width:100%;height:100%;border-radius: 30px;' alt="">
                </div>
                <div>
                  <div class='nickname'>近聘昵称:{{userFriendInfo.nick_name}}</div>
                  <div class='nickname'>近聘账号:{{userFriendInfo.ids}}</div>
                  <div class='nickname'>近聘手机号:{{userFriendInfo.mobile}}</div>
                </div> 
            </div>
        </div>
        <div class='add_btn' @click="addUserFired()">添加好友</div>
    </div>
</template>

<script>
import {Toast} from 'vant'
  export default {
    name: 'reCharge',
    data(){
      return {
        userInfo:'',
        userFriendInfo:''
      }
    },
    components:{
     
    },
    created(){
      let userInfo = localStorage.getItem('userInfo')
      console.log(JSON.parse(userInfo))
      
      
      // console.log(JSON.parse(this.$route.params.jobObj))
      // console.log(JSON.parse(this.$route.params.type))
      this.userFriendInfo = JSON.parse(this.$route.params.jobObj)
      if(this.$route.params.type){
        this.userInfo = JSON.parse(userInfo)
      }
    },
    methods:{
      
       goBack(){
           this.$router.go('-1')
       },
       addUserFired(){
        // CompanyId: ""
        // GroupId: null
        // GroupName: null
        // Id: null
        // LastMessage: "123"
        // MessagePage: "person"
        // MessageType: "0"
        // Mobile: "15527289000"
        // Name: "咆哮的卤蛋"
        // Remark: "无"
        // SelfRemark: "无"
        // UserId: "c0f1ef67-1475-4a06-9a2c-d18e9a62b927"
        // UserImage: "https://jinpin-1304985105.cos.ap-guangzhou.myqcloud.com/image/user_avatar/2022/7/16/6d154838-1339-4b06-8c29-c97712869e9e.bmp"
        // isRead: 0
          // 例如A加B 则A为addUserId  B为addedUserId
          console.log(this.userFriendInfo)
          // let data = {
          //   MessageType:0,
          //   Mobile:this.userFriendInfo.mobile,
          //   Name:this.userFriendInfo.nick_name,
          //   UserId:this.userFriendInfo.id,
          //   UserImage:this.userFriendInfo.avatar
          // }
          // this.signaR.getMessage(data)
          // this.$router.push({name: 'chat', params: data})
          let params = {
            addUserId:this.userInfo.id, 
            addedUserId:this.userFriendInfo.id
          }
          this.$api.user.AddFirend(params).then(res => {
              if (res.code === 200) {
                Toast(res.data)
                console.log(res)
              }
          })
        }
    },
     

  }
</script>

<style scoped lang='scss'>
.head_img_box{
    background: #fff;
    padding:20px 0;
    margin-bottom: 20px;
    .head_img{
      width:90%;
      margin:20px auto;
      display: flex;
      margin-bottom: 40px;
      .head{
          width:60px;
          height:60px;
          // border:1px solid #ccc;
          margin-right: 10px;
          border-radius: 20px;
      }
      .nickname{
          font-size: 16px;
          font-weight: bold;
      }
    }
    
}
  .add_btn{
      text-align: center;
      padding:15px 0;
      color:rgb(171,157,224);
      background: #fff;
      font-size: 14px;
      margin-bottom:10px;
  }
  
  
</style>
